﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CollaborateTools;
using System.Windows.Forms;
using ATEC.ATDataCoreNET;
using System.IO;
using SSDPNET;
using ATEC.ATCore;
using static ATEC.ATCore.ATLoad;
namespace DoModelExample
{
    public class CreateNewProject
    {
        public static string m_ProjectFileName = "";
        /// <summary>
        /// 新建工程
        /// </summary>
        /// <returns></returns>
        public static bool NewProject()
        {
            // step1: 弹窗.  注意：如果弹窗后，“创建”按钮是灰的，说明新建的项目未包含此专业
            NewProjectForm form = new NewProjectForm(DbUsage.TopDownDesign, GNodeType.Tunnel,"Net示例工程");
            form.Text = "新建工程";
            DialogResult r = form.ShowDialog();

            if (r == DialogResult.OK)
            {
                m_ProjectFileName = GetDBName();
                return true;
            }
            else
            {
                return false;
            }

        }
        /// <summary>
        /// 获取工程名 带路径
        /// </summary>
        /// <returns></returns>
        public static string GetDBName()
        {
            ATProject masterATProject = SSDPNET.ATObjFuncs.ProjectObjGetMasterProject();
            string dbFileName = masterATProject.GetFileName();     
            return dbFileName;
        }

        public static void NewDesignFile(string dbFileName)
        {
            bool isTnlProj = dbFileName.Equals(GetDBName());
            if(isTnlProj)
            {
                TreeManager.Entity().CreateProjectTree();
            }
        }
    }
}
